package thread;

import java.util.Scanner;

public class Demo17 {
    private volatile static int isQuit = 0;

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            while (isQuit == 0) {

            }
            System.out.println("t1 退出");
        });

        t1.start();

        Thread t2 = new Thread(() -> {
            System.out.println("请输入isQuit: ");
            Scanner sc = new Scanner(System.in);
            //一旦用户输入的值，不为0，此时就会使t1线程执行结束
            isQuit = sc.nextInt();
        });
        t2.start();
    }
}
